www.gusucode.com > 地方成人教育中心整站源代码 1 > 地方成人教育中心整站源代码 1.0/inc/fso.asp
<% '----------------FSO操作------------------------------ '读取文件 Function FSOFileRead(Template_Name) Dim objFSO,objCountFile,FiletempData Set objFSO = Server.CreateObject("Scripting.FileSystemObject") Set objCountFile = objFSO.OpenTextFile(Server.MapPath(Template_Name),1,True) If objCountFile.AtEndOfStream = false Then FSOFileRead = objCountFile.ReadAll objCountFile.Close Set objCountFile=Nothing Set objFSO = Nothing End Function '创建文件夹 Function CreateFolder(fldr) 'on error resume next Dim fso, f Set fso = CreateObject("Scripting.FileSystemObject") Set f = fso.CreateFolder(Server.MapPath(fldr)) CreateFolder = f.Path Set f=nothing Set fso=nothing Select Case Err Case 424 Response.Write "路径未找到或者该目录没有写入权限." End Select End Function '../HtmlFolder/menu.html '创建文件 Function createhtml(path,str) 'On Error Resume Next GetFold=split(path,"/") For e=0 to Ubound(GetFold)-1 if fldr="" then fldr=GetFold(e) else fldr=fldr&"/"&GetFold(e) end if If IsFolder(fldr)=false then CreateFolder fldr End if Next Set fso = Server.CreateObject("Scripting.FileSystemObject") Set fout = fso.CreateTextFile(server.mappath(path)) fout.Write str fout.close set fso = nothing Select Case Err Case 424 Response.Write "路径未找到或者该目录没有写入权限." End Select End Function '删除文件夹 Function delfolder(path) If IsFolder(path)=True Then Set fso = CreateObject("Scripting.FileSystemObject") fso.DeleteFolder(server.mappath(path)) set fso = Nothing End If End Function '删除文件 Function delfile(path) 'On Error Resume Next If IsExists(path)=True Then set fso = server.CreateObject("Scripting.FileSystemObject") fso.DeleteFile(server.mappath(path)) set fso = nothing End If Select Case Err Case 424 Response.Write "路径未找到或者该目录没有写入权限." End Select End Function '检测文件是否存在 Function IsExists(filespec) Dim fso Set fso = CreateObject("Scripting.FileSystemObject") If (fso.FileExists(server.MapPath(filespec))) Then IsExists = True Else IsExists = False End If Set fso=nothing End Function '检测文件夹是否存在 Function IsFolder(Folder) Set fso = CreateObject("Scripting.FileSystemObject") If FSO.FolderExists(server.MapPath(Folder)) Then IsFolder = True Else IsFolder = False End If Set fso=nothing End Function ' 修改文件夹名称路径 Function fldrename(nowfld,newfld) 'on error resume next if nowfld<>newfld then nowfld=server.mappath(nowfld) newfld=server.mappath(newfld) Set fso = CreateObject("Scripting.FileSystemObject") if not fso.FolderExists(nowfld) then response.write("需要修改的文件夹路径不正确") else fso.CopyFolder nowfld,newfld fso.DeleteFolder(nowfld) end if set fso=nothing Select Case Err Case 424 Response.Write "路径未找到或者该目录没有写入权限." End Select end if End Function %>